package cc.rengu.igas.channel.wechat.biz.impl;

import cc.rengu.igas.channel.wechat.common.constant.WechatServiceConstant;
import cc.rengu.igas.channel.wechat.common.enums.RespCodeEnum;
import cc.rengu.igas.channel.wechat.facade.WechatMsgPushService;
import cc.rengu.igas.channel.wechat.facade.request.*;
import cc.rengu.igas.channel.wechat.facade.response.*;
import cc.rengu.igas.channel.wechat.facade.result.Result;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.DubboResult;
import cc.rengu.oltp.service.realize.DubboService;
import cc.rengu.oltp.service.realize.impl.DubboServiceImpl;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

public class WechatMsgPushServiceImpl implements WechatMsgPushService {
    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());

    @Override
    public Result<MchntAuthMsgPushResponse> mchntAuthMsgPush(MchntAuthMsgPushRequest mchntAuthMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntAuthMsgPushResponse> result = new Result<>();
        MchntAuthMsgPushResponse mchntAuthMsgPushResponse = new MchntAuthMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntAuthMsgPushRequest,
                    WechatServiceConstant.MCHNT_AUTH_MSGPUSH_SERVICE, MchntAuthMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntAuthMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户认证交易消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntAuthMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntAuthMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntAuthMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntAuthMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<ExpandManagerMsgPushResponse> expandManagerMsgPush(ExpandManagerMsgPushRequest expandManagerMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<ExpandManagerMsgPushResponse> result = new Result<>();
        ExpandManagerMsgPushResponse expandManagerMsgPushResponse = new ExpandManagerMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(expandManagerMsgPushRequest,
                    WechatServiceConstant.EXP_MAN_MSGPUSH_SERVICE, ExpandManagerMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((ExpandManagerMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("拓展经理认证消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                expandManagerMsgPushResponse.setRespDesc(((BizException) e).getCode());
                expandManagerMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                expandManagerMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                expandManagerMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<FinancialTransMsgPushResponse> financialTransMsgPush(FinancialTransMsgPushRequest financialTransMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<FinancialTransMsgPushResponse> result = new Result<>();
        FinancialTransMsgPushResponse financialTransMsgPushResponse = new FinancialTransMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(financialTransMsgPushRequest,
                    WechatServiceConstant.FINAN_MSGPUSH_SERVICE, FinancialTransMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((FinancialTransMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("动账交易提醒消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                financialTransMsgPushResponse.setRespDesc(((BizException) e).getCode());
                financialTransMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                financialTransMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                financialTransMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntApplyAcceptMsgPushResponse> mchntApplyAcceptMsgPush(MchntApplyAcceptMsgPushRequest mchntApplyAcceptMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntApplyAcceptMsgPushResponse> result = new Result<>();
        MchntApplyAcceptMsgPushResponse mchntApplyAcceptMsgPushResponse = new MchntApplyAcceptMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntApplyAcceptMsgPushRequest,
                    WechatServiceConstant.MCHNT_APPLY_MSGPUSH_SERVICE, MchntApplyAcceptMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntApplyAcceptMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户申请受理消息推送(商户):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntApplyAcceptMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntApplyAcceptMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntApplyAcceptMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntApplyAcceptMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntApplyRemindMsgPushResponse> mchntApplyRemindMsgPush(MchntApplyRemindMsgPushRequest mchntApplyRemindMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntApplyRemindMsgPushResponse> result = new Result<>();
        MchntApplyRemindMsgPushResponse mchntApplyRemindMsgPushResponse = new MchntApplyRemindMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntApplyRemindMsgPushRequest,
                    WechatServiceConstant.MCHNT_APPLY_REMIND_MSGPUSH_SERVICE, MchntApplyRemindMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntApplyRemindMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户申请提醒消息推送(拓展经理):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntApplyRemindMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntApplyRemindMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntApplyRemindMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntApplyRemindMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<RefundMsgPushResponse> refundMsgPush(RefundMsgPushRequest refundMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<RefundMsgPushResponse> result = new Result<>();
        RefundMsgPushResponse refundMsgPushResponse = new RefundMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(refundMsgPushRequest,
                    WechatServiceConstant.REFUND_MSGPUSH_SERVICE, RefundMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((RefundMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("退款成功提醒消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                refundMsgPushResponse.setRespDesc(((BizException) e).getCode());
                refundMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                refundMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                refundMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<CancelMsgPushResponse> cancelMsgPush(CancelMsgPushRequest cancelMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<CancelMsgPushResponse> result = new Result<>();
        CancelMsgPushResponse cancelMsgPushResponse = new CancelMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(cancelMsgPushRequest,
                    WechatServiceConstant.CANCEL_MSGPUSH_SERVICE, CancelMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((CancelMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("撤销交易成功消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                cancelMsgPushResponse.setRespDesc(((BizException) e).getCode());
                cancelMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                cancelMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                cancelMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntCheckPassMsgPushResponse> mchntCheckPassMsgPush(MchntCheckPassMsgPushRequest mchntCheckPassMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntCheckPassMsgPushResponse> result = new Result<>();
        MchntCheckPassMsgPushResponse mchntCheckPassMsgPushResponse = new MchntCheckPassMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntCheckPassMsgPushRequest,
                    WechatServiceConstant.MCHNT_CHECKPASS_MSGPUSH_SERVICE, MchntCheckPassMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntCheckPassMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户审核通过通知消息推送(拓展经理):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntCheckPassMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntCheckPassMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntCheckPassMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntCheckPassMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntCheckReviewMsgPushResponse> mchntCheckReviewMsgPush(MchntCheckReviewMsgPushRequest mchntCheckReviewMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntCheckReviewMsgPushResponse> result = new Result<>();
        MchntCheckReviewMsgPushResponse mchntCheckReviewMsgPushResponse = new MchntCheckReviewMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntCheckReviewMsgPushRequest,
                    WechatServiceConstant.MCHNT_CHECK_REVIEW_MSGPUSH_SERVICE, MchntCheckReviewMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntCheckReviewMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户审核通过待认证消息推送(拓展经理):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntCheckReviewMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntCheckReviewMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntCheckReviewMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntCheckReviewMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<DispatchMsgPushResponse> dispatchMsgPush(DispatchMsgPushRequest dispatchMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<DispatchMsgPushResponse> result = new Result<>();
        DispatchMsgPushResponse dispatchMsgPushResponse = new DispatchMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(dispatchMsgPushRequest,
                    WechatServiceConstant.DISPATCH_MSGPUSH_SERVICE, DispatchMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((DispatchMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("派单通知消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                dispatchMsgPushResponse.setRespDesc(((BizException) e).getCode());
                dispatchMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                dispatchMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                dispatchMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<CheckFailMsgPushResponse> checkFailMsgPush(CheckFailMsgPushRequest checkFailMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<CheckFailMsgPushResponse> result = new Result<>();
        CheckFailMsgPushResponse checkFailMsgPushResponse = new CheckFailMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(checkFailMsgPushRequest,
                    WechatServiceConstant.CHECKFAIL_MSGPUSH_SERVICE, CheckFailMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((CheckFailMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("审核未通过通知:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                checkFailMsgPushResponse.setRespDesc(((BizException) e).getCode());
                checkFailMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                checkFailMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                checkFailMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntCheckPushResponse> mchntCheckPush(MchntCheckPushRequest mchntCheckPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntCheckPushResponse> result = new Result<>();
        MchntCheckPushResponse mchntCheckPushResponse = new MchntCheckPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntCheckPushRequest,
                    WechatServiceConstant.MCHNT_CHECK_MSGPUSH_SERVICE, MchntCheckPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntCheckPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户待审核通知(审核员):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntCheckPushResponse.setRespDesc(((BizException) e).getCode());
                mchntCheckPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntCheckPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntCheckPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<MchntInfoUpdateMsgPushResponse> mchntInfoUpdateMsgPush(MchntInfoUpdateMsgPushRequest mchntInfoUpdateMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<MchntInfoUpdateMsgPushResponse> result = new Result<>();
        MchntInfoUpdateMsgPushResponse mchntInfoUpdateMsgPushResponse = new MchntInfoUpdateMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(mchntInfoUpdateMsgPushRequest,
                    WechatServiceConstant.MCHNTINFO_UPDATE_MSGPUSH_SERVICE, MchntInfoUpdateMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((MchntInfoUpdateMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("商户资料修改消息推送(拓展经理):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                mchntInfoUpdateMsgPushResponse.setRespDesc(((BizException) e).getCode());
                mchntInfoUpdateMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                mchntInfoUpdateMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mchntInfoUpdateMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<QrcodeStopMsg2managerPushResponse> qrcodeStopMsg2managerPush(QrcodeStopMsg2managerPushRequest qrcodeStopMsg2managerPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<QrcodeStopMsg2managerPushResponse> result = new Result<>();
        QrcodeStopMsg2managerPushResponse qrcodeStopMsg2managerPushResponse = new QrcodeStopMsg2managerPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(qrcodeStopMsg2managerPushRequest,
                    WechatServiceConstant.QRCODE_STOP_MAN_MSGPUSH_SERVICE, QrcodeStopMsg2managerPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((QrcodeStopMsg2managerPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("二维码停用通知(拓展经理):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                qrcodeStopMsg2managerPushResponse.setRespDesc(((BizException) e).getCode());
                qrcodeStopMsg2managerPushResponse.setRespDesc(e.getMessage());
            } else {
                qrcodeStopMsg2managerPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                qrcodeStopMsg2managerPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<QrcodeStopMsg2MchntPushResponse> qrcodeStopMsg2MchntPush(QrcodeStopMsg2MchntPushRequest qrcodeStopMsg2MchntPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<QrcodeStopMsg2MchntPushResponse> result = new Result<>();
        QrcodeStopMsg2MchntPushResponse qrcodeStopMsg2MchntPushResponse = new QrcodeStopMsg2MchntPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(qrcodeStopMsg2MchntPushRequest,
                    WechatServiceConstant.MCHNT_QRCODE_STOP_MSGPUSH_SERVICE, QrcodeStopMsg2MchntPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((QrcodeStopMsg2MchntPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("二维码停用通知(商户):<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                qrcodeStopMsg2MchntPushResponse.setRespDesc(((BizException) e).getCode());
                qrcodeStopMsg2MchntPushResponse.setRespDesc(e.getMessage());
            } else {
                qrcodeStopMsg2MchntPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                qrcodeStopMsg2MchntPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<CertExprMsgPushResponse> certExprMsgPush(CertExprMsgPushRequest certExprMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<CertExprMsgPushResponse> result = new Result<>();
        CertExprMsgPushResponse certExprMsgPushResponse = new CertExprMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(certExprMsgPushRequest,
                    WechatServiceConstant.CERTEXPR_MSGPUSH_SERVICE, CertExprMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((CertExprMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("证件到期提醒消息推送:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                certExprMsgPushResponse.setRespDesc(((BizException) e).getCode());
                certExprMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                certExprMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                certExprMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UnifiedMsgPushResponse> unifiedMsgPush(UnifiedMsgPushRequest unifiedMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<UnifiedMsgPushResponse> result = new Result<>();
        UnifiedMsgPushResponse unifiedMsgPushResponse = new UnifiedMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(unifiedMsgPushRequest,
                    WechatServiceConstant.UNIFIED_MSGPUSH_SERVICE, UnifiedMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UnifiedMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("提醒消息推送失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                unifiedMsgPushResponse.setRespDesc(((BizException) e).getCode());
                unifiedMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                unifiedMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                unifiedMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<InspectCheckMsgPushResponse> inspectCheckMsgPush(InspectCheckMsgPushRequest inspectCheckMsgPushRequest) throws Exception {
        DubboService dubboService = new DubboServiceImpl();
        Result<InspectCheckMsgPushResponse> result = new Result<>();
        InspectCheckMsgPushResponse inspectCheckMsgPushResponse = new InspectCheckMsgPushResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(inspectCheckMsgPushRequest,
                    WechatServiceConstant.INSPECT_MSGPUSH_SERVICE, InspectCheckMsgPushResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((InspectCheckMsgPushResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("提醒消息推送失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                inspectCheckMsgPushResponse.setRespDesc(((BizException) e).getCode());
                inspectCheckMsgPushResponse.setRespDesc(e.getMessage());
            } else {
                inspectCheckMsgPushResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                inspectCheckMsgPushResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }
}
